// pages/indexAll/shiyanList/shiyanList.js
const app = getApp()
var self;
var nowpage = 1;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    searchTxt: "",
    shiyanList: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
      self = this;
    nowpage = 1;
    self.getShiyanList();
  }, 
  getShiyanList: function () {
    //开始搜集搜索项
    var ShiYanShiMingCheng = self.data.searchTxt;
    if (nowpage > 1) {
      wx.showLoading({
        title: '正在加载',
      })
    }
    wx.request({
      url: app.globalData.apiUrl + "IS05/HIS050100.ashx?Method=GetShiYanShiList",
      data: {
        ShiYanShiMingCheng: ShiYanShiMingCheng,
        rows: 4,
        page: nowpage
      },
      method: 'GET',
      success: function (res) {
        setTimeout(function () {
          wx.hideLoading();
        }, 500);

        if (res.data.state == 1) {

          var tmplist = self.data.shiyanList;
          var shiyanList = res.data.retData.ShiYanShiList;
          if (shiyanList.length > 0) {
            nowpage++;
            for (var i = 0; i < shiyanList.length; i++) {
              tmplist.push(shiyanList[i]);
            }
            self.setData({
              shiyanList: tmplist
            })
          } else {
            wx.showToast({
              title: '暂无更多数据',
              icon: 'none'
            })
          }

        }
      }
    });
  },
  goYuyue:function(e){
    wx.navigateTo({
      url: '/pages/indexAll/shiyanStep/shiyanStep?id=' + e.currentTarget.dataset.id,
    })
  },
  goSearch() {
    nowpage = 1;
    self.setData({
      shiyanList: []
    })
    self.getShiyanList();

  },
  changeTxt: function (e) {
    self.setData({
      searchTxt: e.detail.value
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})